package 多线程;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

public class Piao {
        public  static synchronized void one(){
            for (int i = 0; i <5 ; i++) {
                System.out.println(Thread.currentThread().getName()+"one() is running");
                try{
                    TimeUnit.SECONDS.sleep(1);
                }catch(InterruptedException e ){
                    e.printStackTrace();
                }

            }
        }
    public static  synchronized void two(){
        for (int i = 0; i <4 ; i++) {
            System.out.println(Thread.currentThread().getName()+"two() is running");
            try{
                TimeUnit.SECONDS.sleep(3);
            }catch(InterruptedException e ){
                e.printStackTrace();
            }

        }
    }
    public static synchronized void three(){
        for (int i = 0; i <6 ; i++) {
            System.out.println(Thread.currentThread().getName()+"three() is running");
            try{
                TimeUnit.SECONDS.sleep(2);
            }catch(InterruptedException e ){
                e.printStackTrace();
            }

        }
    }
    public static synchronized void four(){
        for (int i = 0; i <2 ; i++) {
            System.out.println(Thread.currentThread().getName()+"four() is running");
            try{
                TimeUnit.SECONDS.sleep(4);
            }catch(InterruptedException e ){
                e.printStackTrace();
            }

        }
    }




    public static void main(String[] args) {
            Piao piao = new Piao();
            new Thread(()->piao.one()).start();
            new Thread(()->piao.two()).start();
            new Thread(()->piao.three()).start();
            new Thread(()->piao.four()).start();
            piao.one();

        }
    }


